<div id="tabs">
	<ul>
        <li id="current"><?php echo $this->Html->link(__('Danh sách đơn vị', true), array('controller'=>'thuocdvs','action' => 'index')); ?></li>
        <li><?php echo $this->Html->link(__('Thêm đơn vị', true), array('controller'=>'thuocdvs','action' => 'adddv')); ?></li>
    </ul>
</div>
<div class="donvis index">
	<h2><?php __('Danh sách các đơn vị');?></h2>
	<?php echo $form->create('Thuocdv');?>
	<table>
  		<tr>
 			<td><?php echo $form->input('ct',array('id'=>'ct','label'=>'Công ty','options'=>$donvis,'empty'=>'---Tất Cả---'));?></td>
  			<td><div id='cn'><?php echo $form->input('cn',array('id'=>'cn','label'=>'Chi nhánh','options'=>$cnhanhs,'empty'=>'Chọn Đơn vị'));?></div></td>
  		</tr>
  	</table>
  	<?php echo $form->end();?>
	<div id='dv'>
	<table cellpadding="0" cellspacing="0" id="tables">
	<tr>
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Mã đơn vị';?></th>
			<th><?php echo 'Tên đơn vị';?></th>
			<th><?php echo 'Địa chỉ';?></th>
			<th><?php echo 'Đơn vị trực thuộc';?></th>
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
	<?php
	$i = 0;$stt=0;
	foreach ($thuocdvs as $donvi):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td><?php echo $stt=$stt+1; ?>&nbsp;</td>
		<td><?php echo $donvi['Donvi']['madv']; ?>&nbsp;</td>
		<td><?php echo $donvi['Donvi']['tendv']; ?>&nbsp;</td>
		<td><?php echo $donvi['Donvi']['diachi']; ?>&nbsp;</td>
		<td><?php echo $donvi['Donvicha']['tendv']; ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Html->link(__('Sửa', true), array('action' => 'editdv', $donvi['Thuocdv']['id'])); ?>
			<?php //echo $this->Html->link(__('Xóa', true), array('action' => 'delete', $donvi['Donvi']['id']), null, sprintf(__('Bạn muốn xóa đơn vị %s?', true), $donvi['Donvi']['madv'])); ?>
		
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('Trước', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('Sau', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>
</div>
<?php
$this->Js->get('#ct')->event('change',
							$this->Js->request(array('controller' => 'thuocdvs', 'action' => 'laycn'),
							array('update' => '#cn','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));

$this->Js->get('#ct')->event('change',
							$this->Js->request(array('controller' => 'thuocdvs', 'action' => 'laydv'),
							array('update' => '#dv','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true))))); 

$this->Js->get('#cn')->event('change',
							$this->Js->request(array('controller' => 'thuocdvs', 'action' => 'laydv'),
							array('update' => '#dv','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true))))); 
							
?>